//
//  XinLiCePingTestTCell.m
//  students
//
//  Created by 任辰东 on 2024/3/4.
//

#import "XinLiCePingTestTCell.h"
#import "XinLiCePingOptionsView.h"

@interface XinLiCePingTestTCell ()
@property (nonatomic, strong) UIView *containerView;
@property (nonatomic, strong) UILabel *titleLabel;
@property (nonatomic, strong) XinLiCePingOptionsView *optionsView;
@end

@implementation XinLiCePingTestTCell

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

-(void)configCellWithModel:(XinLiCePingModel *)model
{
    self.titleLabel.text = [NSString stringWithFormat:@"%@.%@",model.ti_id,model.ti_title];
    [self.optionsView configViewWithModel:model];
    [self.contentView layoutIfNeeded];
    
}

-(void)setupViews
{
    self.contentView.backgroundColor = UIColorFromHex(kColorBG);
    [self.contentView addSubview:self.containerView];
    [self.containerView addSubview:self.titleLabel];
    [self.containerView addSubview:self.optionsView];
    
    WeakSelf
    [self.optionsView setSelectedBlock:^(XinLiCePingOptionsModel * _Nonnull model) {
           StrongSelf
        if (self.SelectedBlock) {
            self.SelectedBlock(model);
        }
        
    }];
}

-(void)setupLayout
{
    [self.containerView mas_makeConstraints:^(MASConstraintMaker *make) {
       
//        make.top.left.right.equalTo(self.contentView);
//        make.bottom.equalTo(self.contentView).offset(0);
        make.edges.equalTo(self.contentView);
    }];
    
    [self.titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.top.equalTo(self.containerView).offset(15);
        make.left.equalTo(self.containerView).offset(15);
        make.right.equalTo(self.containerView).offset(-15);
    }];
    
    [self.optionsView mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.top.equalTo(self.titleLabel.mas_bottom).offset(5);
        make.left.equalTo(self.containerView).offset(0);
        make.right.equalTo(self.containerView).offset(0);
        make.bottom.equalTo(self.containerView).offset(-5);
    }];
}

#pragma mark -- lazyload

-(UIView *)containerView
{
    if (!_containerView) {
        _containerView = [UIView new];
        _containerView.backgroundColor = UIColorFromHex(kColorWhite);
        [_containerView addBottomLine];
    }
    return _containerView;
}

-(UILabel *)titleLabel
{
    if (!_titleLabel) {
        _titleLabel = [UILabel new];
        _titleLabel.text = @"时间";
        _titleLabel.textColor = UIColorFromHex(0x000000);
        _titleLabel.numberOfLines = 0;
        _titleLabel.font = UIFontSize(16);
    }
    return _titleLabel;
}

-(XinLiCePingOptionsView *)optionsView
{
    if (!_optionsView) {
        _optionsView = [XinLiCePingOptionsView new];
    }
    return _optionsView;
}

@end
